package com.gqj.elec.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.gqj.common.annotation.Log;
import com.gqj.common.core.controller.BaseController;
import com.gqj.common.core.domain.AjaxResult;
import com.gqj.common.enums.BusinessType;
import com.gqj.elec.domain.ElecMaterialIndetail;
import com.gqj.elec.service.IElecMaterialIndetailService;
import com.gqj.common.utils.poi.ExcelUtil;
import com.gqj.common.core.page.TableDataInfo;

/**
 * 物资入库详情Controller
 * 
 * @author lxq
 * @date 2023-12-17
 */
@RestController
@RequestMapping("/elec/elecMaterialInDetail")
public class ElecMaterialIndetailController extends BaseController
{
    @Autowired
    private IElecMaterialIndetailService elecMaterialIndetailService;

    /**
     * 查询物资入库详情列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialInDetail:list')")
    @GetMapping("/list")
    public TableDataInfo list(ElecMaterialIndetail elecMaterialIndetail)
    {
        startPage();
        List<ElecMaterialIndetail> list = elecMaterialIndetailService.selectElecMaterialIndetailList(elecMaterialIndetail);
        return getDataTable(list);
    }

    /**
     * 导出物资入库详情列表
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialInDetail:export')")
    @Log(title = "物资入库详情", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ElecMaterialIndetail elecMaterialIndetail)
    {
        List<ElecMaterialIndetail> list = elecMaterialIndetailService.selectElecMaterialIndetailList(elecMaterialIndetail);
        ExcelUtil<ElecMaterialIndetail> util = new ExcelUtil<ElecMaterialIndetail>(ElecMaterialIndetail.class);
        util.exportExcel(response, list, "物资入库详情数据");
    }

    /**
     * 获取物资入库详情详细信息
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialInDetail:query')")
    @GetMapping(value = "/{indetailId}")
    public AjaxResult getInfo(@PathVariable("indetailId") Long indetailId)
    {
        return AjaxResult.success(elecMaterialIndetailService.selectElecMaterialIndetailByIndetailId(indetailId));
    }

    /**
     * 新增物资入库详情
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialInDetail:add')")
    @Log(title = "物资入库详情", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ElecMaterialIndetail elecMaterialIndetail)
    {
        return toAjax(elecMaterialIndetailService.insertElecMaterialIndetail(elecMaterialIndetail));
    }

    /**
     * 修改物资入库详情
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialInDetail:edit')")
    @Log(title = "物资入库详情", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ElecMaterialIndetail elecMaterialIndetail)
    {
        return toAjax(elecMaterialIndetailService.updateElecMaterialIndetail(elecMaterialIndetail));
    }

    /**
     * 删除物资入库详情
     */
    @PreAuthorize("@ss.hasPermi('elec:elecMaterialInDetail:remove')")
    @Log(title = "物资入库详情", businessType = BusinessType.DELETE)
	@DeleteMapping("/{indetailIds}")
    public AjaxResult remove(@PathVariable Long[] indetailIds)
    {
        return toAjax(elecMaterialIndetailService.deleteElecMaterialIndetailByIndetailIds(indetailIds));
    }
}
